home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- Caption = "Form1"
- ClientHeight = 5820
- ClientLeft = 1095
- ClientTop = 1770
- ClientWidth = 7365
- Height = 6510
- Left = 1035
- LinkTopic = "Form1"
- ScaleHeight = 5820
- ScaleWidth = 7365
- Top = 1140
- Width = 7485
- Begin FileListBox File1
- Height = 3735
- Left = 180
- TabIndex = 3
- Top = 1005
- Width = 1560
- End
- Begin DriveListBox Drive1
- Height = 315
- Left = 1980
- TabIndex = 2
- Top = 4455
- Width = 2130
- End
- Begin DirListBox Dir1
- Height = 3180
- Left = 1935
- TabIndex = 1
- Top = 1005
- Width = 2160
- End
- Begin PictureBox Picture1
- AutoRedraw = -1 'True
- AutoSize = -1 'True
- Height = 1335
- Left = 5325
- ScaleHeight = 1305
- ScaleWidth = 1185
- TabIndex = 0
- Top = 2985
- Width = 1215
- End
- Begin Menu mnuExit
- Caption = "Exit"
- End
- 'Functions for extracting and drawing icons
- Declare Function GetModuleHandle Lib "Kernel" (ByVal lpModuleName As String) As Integer
- Declare Function GetClassWord Lib "User" (ByVal hWnd As Integer, ByVal nIndex As Integer) As Integer
- Declare Function ExtractIcon Lib "SHELL" (ByVal hInst As Integer, ByVal lpszexename As String, ByVal hIcon As Integer) As Integer
- Declare Function DrawIcon Lib "User" (ByVal hDC As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal hIcon As Integer) As Integer
- ' Window field offsets for GetClassWord() and GetWindowWord().
- Const GWW_HINSTANCE = (-6)
- Const GCW_HMODULE = (-16)
- Sub Dir1_Change ()
- File1.Path = Dir1.Path
- End Sub
- Sub Drive1_Change ()
- Dir1.Path = Drive1.Drive
- End Sub
- Sub File1_Click ()
- Call GetIcon
- End Sub
- Sub Form_Unload (Cancel As Integer)
- End
- End Sub
- Sub GetIcon ()
- Dim hInst As Integer, hIcon As Integer
- ' Clear the previous image from the picture box
- Picture1.Picture = LoadPicture("")
- 'Get the instance handle for the form
- hInst = GetClassWord(hWnd, GCW_HMODULE)
- ' The path and filename of program to extract icon from.
- lpzxExeName$ = File1.Path & "\" & File1.FileName
- 'Get handle to first icon in the file.
- 'This function will only recognize files with extensions of .exe, .dll,
- 'or .ico as being valid filenames, therefore, it returns 1 for any other
- 'extension, such as .pif. It also returns 1 if the file DOES have an
- '.exe extension but is a DOS program.
- 'It returns 0 for a valid filename that contains no icons
- 'The third argument specifies the index of the icon to be
- 'retrieved. If this parameter is zero, the function returns
- 'the handle of the first icon in the specified file. If the
- 'parameter is -1, the function returns the total number of
- 'icons in the specified file.
- hIcon = ExtractIcon(hInst, lpzxExeName$, 0)
- Select Case hIcon
- Case 1
- Msg$ = "Not a valid extension or a DOS program"
- MsgBox Msg$
- Case 0
- Msg$ = "No icons exist in the specified file."
- MsgBox Msg$
- Case Else
- 'Draw the icon in the picture box
- r% = DrawIcon(Picture1.hDC, 0, 0, hIcon)
- Picture1.Refresh
- End Select
-
- End Sub
- Sub mnuExit_Click ()
- Unload Me
- End Sub
-